package com.loan.controller;

import com.loan.service.SendSmsService;
import com.loan.utils.ResponseResult;
//import com.thx.service.AliYunSmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 发送验证码controller
 * @author z
 */
@RestController
@Slf4j
@Api(tags = "发送验证码")
@RequestMapping("/sendSms")
public class SendSmsController {
//    @Resource
//    private AliYunSmsService aliYunSmsService;
    @Resource
    private RedisTemplate<String, String> redisTemplate;
    @Resource
    private SendSmsService sendSmsService;


    @PostMapping("/{phone}")
    @ApiOperation(value = "发送验证码",httpMethod = "POST",notes = "发送验证码")
    public ResponseResult<?> sendSms(@PathVariable String phone) {
        //boolean b = sendSmsService.sendSms(phone);
        boolean b = sendSmsService.sendSmsNull(phone);
        if (b) {
            return ResponseResult.success("验证码发送成功");
        }
        return ResponseResult.failed("验证码发送失败");
        }
    }
